<!--
Copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML header for doxygen 1.8.9.1-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<title>Boost.Hana: Struct</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  $(document).ready(function() { init_search(); });
/* @license-end */
</script>
<script type="text/x-mathjax-config">
  MathJax.Hub.Config({
    extensions: ["tex2jax.js"],
    jax: ["input/TeX","output/HTML-CSS"],
});
// Copyright Louis Dionne 2013-2017
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
MathJax.Hub.Config({
    "HTML-CSS": {
        linebreaks: {
            automatic: true,
            width: "75% container"
        }
    }
});
</script>
<script type="text/javascript" async="async" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<!-- Additional javascript for drawing charts. -->
<script type="text/javascript" src="highcharts.js"></script>
<script type="text/javascript" src="highcharts-data.js"></script>
<script type="text/javascript" src="highcharts-exporting.js"></script>
<script type="text/javascript" src="chart.js"></script>
<script type="text/javascript" src="hana.js"></script>
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><img alt="Logo" src="Boost.png"/></td>
  <td style="padding-left: 0.5em;">
   <div id="projectname">Boost.Hana
   &#160;<span id="projectnumber">1.7.1</span>
   </div>
   <div id="projectbrief">Your standard library for metaprogramming</div>
  </td>
   <td>        <div id="MSearchBox" class="MSearchBoxInactive">
        <span class="left">
          <img id="MSearchSelect" src="search/mag_sel.svg"
               onmouseover="return searchBox.OnSearchSelectShow()"
               onmouseout="return searchBox.OnSearchSelectHide()"
               alt=""/>
          <input type="text" id="MSearchField" value="Search" accesskey="S"
               onfocus="searchBox.OnSearchFieldFocus(true)" 
               onblur="searchBox.OnSearchFieldFocus(false)" 
               onkeyup="searchBox.OnSearchFieldChange(event)"/>
          </span><span class="right">
            <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
          </span>
        </div>
</td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'Search','.html');
/* @license-end */
</script>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('group__group-_struct.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a> &#124;
<a href="#var-members">Variables</a>  </div>
  <div class="headertitle">
<div class="title">Struct<div class="ingroups"><a class="el" href="group__group-concepts.html">Concepts</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">Description</h2>
<p>The <code>Struct</code> concept represents <code>struct</code>-like user-defined types. </p>
<p>The <code>Struct</code> concept allows restricted compile-time reflection over user-defined types. In particular, it allows accessing the names of the members of a user-defined type, and also the value of those members. <code>Struct</code>s can also be folded, searched and converted to some types of containers, where more advanced transformations can be performed.</p>
<p>While all types can <em>in theory</em> be made <code>Struct</code>s, only a subset of them are actually interesting to see as such. More precisely, it is only interesting to make a type a <code>Struct</code> when it is conceptually a C++ <code>struct</code>, i.e. a mostly dumb aggregate of named data. The way this data is accessed is mostly unimportant to the <code>Struct</code> concept; it could be through getters and setters, through public members, through non-member functions or it could even be generated on-the-fly. The important part, which is made precise below, is that those accessor methods should be move-independent.</p>
<p>Another way to see a <code>Struct</code> is as a map where the keys are the names of the members and the values are the values of those members. However, there are subtle differences like the fact that one can't add a member to a <code>Struct</code>, and also that the order of the members inside a <code>Struct</code> plays a role in determining the equality of <code>Struct</code>s, which is not the case for maps.</p>
<h2><a class="anchor" id="autotoc_md175"></a>
Minimal complete definition</h2>
<p><code>accessors</code></p>
<p>A model of <code>Struct</code> is created by specifying a sequence of key/value pairs with the <code>accessors</code> function. The first element of a pair in this sequence represents the "name" of a member of the <code>Struct</code>, while the second element is a function which retrieves this member from an object. The "names" do not have to be in any special form; they just have to be compile-time <code>Comparable</code>. For example, it is common to provide "names" that are <code><a class="el" href="structboost_1_1hana_1_1string.html" title="Compile-time string.">hana::string</a></code>s representing the actual names of the members, but one could provide <code><a class="el" href="structboost_1_1hana_1_1integral__constant.html" title="Compile-time value of an integral type.">hana::integral_constant</a></code>s just as well. The values must be functions which, when given an object, retrieve the appropriate member from it.</p>
<p>There are several ways of providing the <code>accessors</code> method, some of which are more flexible and others which are more convenient. First, one can define it through tag-dispatching, as usual. </p><div class="fragment"><div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    std::string name;</div>
<div class="line">    <span class="keywordtype">int</span> age;</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="comment">// The keys can be anything as long as they are compile-time comparable.</span></div>
<div class="line">constexpr <span class="keyword">auto</span> name = hana::integral_c&lt;std::string Person::*, &amp;Person::name&gt;;</div>
<div class="line">constexpr <span class="keyword">auto</span> age = hana::string_c&lt;&#39;a&#39;, &#39;g&#39;, &#39;e&#39;&gt;;</div>
<div class="line"> </div>
<div class="line"><span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>hana {</div>
<div class="line">    <span class="keyword">template</span> &lt;&gt;</div>
<div class="line">    <span class="keyword">struct </span>accessors_impl&lt;Person&gt; {</div>
<div class="line">        <span class="keyword">static</span> BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> <a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>() {</div>
<div class="line">            <span class="keywordflow">return</span> make_tuple(</div>
<div class="line">                make_pair(name, [](<span class="keyword">auto</span>&amp;&amp; p) -&gt; decltype(<span class="keyword">auto</span>) {</div>
<div class="line">                    <span class="keywordflow">return</span> <a class="code" href="group__group-functional.html#gaef38cf34324c8edbd3597ae71811d00d">id</a>(std::forward&lt;decltype(p)&gt;(p).name);</div>
<div class="line">                }),</div>
<div class="line">                make_pair(age, [](<span class="keyword">auto</span>&amp;&amp; p) -&gt; decltype(<span class="keyword">auto</span>) {</div>
<div class="line">                    <span class="keywordflow">return</span> <a class="code" href="group__group-functional.html#gaef38cf34324c8edbd3597ae71811d00d">id</a>(std::forward&lt;decltype(p)&gt;(p).age);</div>
<div class="line">                })</div>
<div class="line">            );</div>
<div class="line">        }</div>
<div class="line">    };</div>
<div class="line">}}</div>
<div class="ttc" id="agroup__group-functional_html_ga30027c383676084be151ef3c6cf2829f"><div class="ttname"><a href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">boost::hana::apply</a></div><div class="ttdeci">constexpr auto apply</div><div class="ttdoc">Invokes a Callable with the given arguments.</div><div class="ttdef"><b>Definition:</b> apply.hpp:40</div></div>
<div class="ttc" id="agroup__group-functional_html_gaef38cf34324c8edbd3597ae71811d00d"><div class="ttname"><a href="group__group-functional.html#gaef38cf34324c8edbd3597ae71811d00d">boost::hana::id</a></div><div class="ttdeci">constexpr auto id</div><div class="ttdoc">The identity function – returns its argument unchanged.</div><div class="ttdef"><b>Definition:</b> id.hpp:23</div></div>
</div><!-- fragment --><p> Secondly, it is possible to provide a nested <code>hana_accessors_impl</code> type, which should be equivalent to a specialization of <code>accessors_impl</code> for tag-dispatching. However, for a type <code>S</code>, this technique only works when the data type of <code>S</code> is <code>S</code> itself, which is the case unless you explicitly asked for something else. </p><div class="fragment"><div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    std::string name;</div>
<div class="line">    <span class="keywordtype">int</span> age;</div>
<div class="line"> </div>
<div class="line">    <span class="keyword">struct </span>hana_accessors_impl {</div>
<div class="line">        <span class="keyword">static</span> BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> <a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>() {</div>
<div class="line">            <span class="keywordflow">return</span> boost::hana::make_tuple(</div>
<div class="line">                boost::hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>),</div>
<div class="line">                [](<span class="keyword">auto</span>&amp;&amp; p) -&gt; decltype(<span class="keyword">auto</span>) {</div>
<div class="line">                    <span class="keywordflow">return</span> <a class="code" href="group__group-functional.html#gaef38cf34324c8edbd3597ae71811d00d">boost::hana::id</a>(std::forward&lt;decltype(p)&gt;(p).name);</div>
<div class="line">                }),</div>
<div class="line">                boost::hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>),</div>
<div class="line">                [](<span class="keyword">auto</span>&amp;&amp; p) -&gt; decltype(<span class="keyword">auto</span>) {</div>
<div class="line">                    <span class="keywordflow">return</span> <a class="code" href="group__group-functional.html#gaef38cf34324c8edbd3597ae71811d00d">boost::hana::id</a>(std::forward&lt;decltype(p)&gt;(p).age);</div>
<div class="line">                })</div>
<div class="line">            );</div>
<div class="line">        }</div>
<div class="line">    };</div>
<div class="line">};</div>
</div><!-- fragment --><p> Finally, the most convenient (but least flexible) option is to use the <code>BOOST_HANA_DEFINE_STRUCT</code>, the <code>BOOST_HANA_ADAPT_STRUCT</code> or the <code>BOOST_HANA_ADAPT_ADT</code> macro, which provide a minimal syntactic overhead. See the documentation of these macros for details on how to use them.</p>
<p>Also note that it is not important that the accessor functions retrieve an actual member of the struct (e.g. <code>x.member</code>). Indeed, an accessor function could call a custom getter or even compute the value of the member on the fly: </p><div class="fragment"><div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    Person(std::string <span class="keyword">const</span>&amp; name, <span class="keywordtype">int</span> age) : name_(name), age_(age) { }</div>
<div class="line"> </div>
<div class="line">    std::string <span class="keyword">const</span>&amp; get_name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> name_; }</div>
<div class="line">    <span class="keywordtype">int</span> get_age()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> age_; }</div>
<div class="line"> </div>
<div class="line"><span class="keyword">private</span>:</div>
<div class="line">    std::string name_;</div>
<div class="line">    <span class="keywordtype">int</span> age_;</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>hana {</div>
<div class="line">    <span class="keyword">template</span> &lt;&gt;</div>
<div class="line">    <span class="keyword">struct </span>accessors_impl&lt;Person&gt; {</div>
<div class="line">        <span class="keyword">static</span> BOOST_HANA_CONSTEXPR_LAMBDA <span class="keyword">auto</span> <a class="code" href="group__group-functional.html#ga30027c383676084be151ef3c6cf2829f">apply</a>() {</div>
<div class="line">            <span class="keywordflow">return</span> make_tuple(</div>
<div class="line">                make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), [](<span class="keyword">auto</span>&amp;&amp; p) -&gt; std::string <span class="keyword">const</span>&amp; {</div>
<div class="line">                    <span class="keywordflow">return</span> p.get_name();</div>
<div class="line">                }),</div>
<div class="line">                make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>), [](<span class="keyword">auto</span>&amp;&amp; p) {</div>
<div class="line">                    <span class="keywordflow">return</span> p.get_age();</div>
<div class="line">                })</div>
<div class="line">            );</div>
<div class="line">        }</div>
<div class="line">    };</div>
<div class="line">}}</div>
</div><!-- fragment --><p> The only important thing is that the accessor functions are move-independent, a notion which is defined below.</p>
<p><a class="anchor" id="move-independence"></a></p>
<h2><a class="anchor" id="autotoc_md176"></a>
Move-independence</h2>
<p>The notion of move-independence presented here defines rigorously when it is legitimate to "double-move" from an object.</p>
<p>A collection of functions <code>f1, ..., fn</code> sharing the same domain is said to be <em>move-independent</em> if for every fresh (not moved-from) object <code>x</code> in the domain, any permutation of the following statements is valid and leaves the <code>zk</code> objects in a fresh (not moved-from) state: </p><div class="fragment"><div class="line"><span class="keyword">auto</span> z1 = f1(std::move(x));</div>
<div class="line">...</div>
<div class="line">auto zn = fn(std::move(x));</div>
</div><!-- fragment --><dl class="section note"><dt>Note</dt><dd>In the special case where some functions return objects that can't be bound to with <code>auto zk =</code> (like <code>void</code> or a non-movable, non-copyable type), just pretend the return value is ignored.</dd></dl>
<p>Intuitively, this ensures that we can treat <code>f1, ..., fn</code> as "accessors" that decompose <code>x</code> into independent subobjects, and that do so without moving from <code>x</code> more than that subobject. This is important because it allows us to optimally decompose <code>Struct</code>s into their subparts inside the library.</p>
<h2><a class="anchor" id="autotoc_md177"></a>
Laws</h2>
<p>For any <code>Struct</code> <code>S</code>, the accessors in the <code>accessors&lt;S&gt;()</code> sequence must be move-independent, as defined above.</p>
<h2><a class="anchor" id="autotoc_md178"></a>
Refined concepts</h2>
<ol type="1">
<li><code>Comparable</code> (free model)<br  />
<code>Struct</code>s are required to be <code>Comparable</code>. Specifically, two <code>Struct</code>s of the same data type <code>S</code> must be equal if and only if all of their members are equal. By default, a model of <code>Comparable</code> doing just that is provided for models of <code>Struct</code>. In particular, note that the comparison of the members is made in the same order as they appear in the <code><a class="el" href="group__group-_struct.html#gad301dd8e9fb4639d7874619c97d6d427" title="Returns a Sequence containing the members of a Struct.">hana::members</a></code> sequence. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="define__struct_8hpp.html">boost/hana/define_struct.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="keys_8hpp.html">boost/hana/keys.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="string_8hpp.html">boost/hana/string.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    <a class="code" href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">BOOST_HANA_DEFINE_STRUCT</a>(Person,</div>
<div class="line">        (std::string, name),</div>
<div class="line">        (<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>, age)</div>
<div class="line">    );</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    Person john{<span class="stringliteral">&quot;John&quot;</span>, 30}, kevin{<span class="stringliteral">&quot;Kevin&quot;</span>, 20};</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(john, john));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd">hana::not_equal</a>(john, kevin));</div>
<div class="line">}</div>
<div class="ttc" id="aassert_8hpp_html"><div class="ttname"><a href="assert_8hpp.html">assert.hpp</a></div><div class="ttdoc">Defines macros to perform different kinds of assertions.</div></div>
<div class="ttc" id="adefine__struct_8hpp_html"><div class="ttname"><a href="define__struct_8hpp.html">define_struct.hpp</a></div><div class="ttdoc">Defines the BOOST_HANA_DEFINE_STRUCT macro.</div></div>
<div class="ttc" id="aequal_8hpp_html"><div class="ttname"><a href="equal_8hpp.html">equal.hpp</a></div><div class="ttdoc">Defines boost::hana::equal.</div></div>
<div class="ttc" id="agroup__group-_comparable_html_gacaf1ebea6b3ab96ac9dcb82f0e64e547"><div class="ttname"><a href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">boost::hana::equal</a></div><div class="ttdeci">constexpr auto equal</div><div class="ttdoc">Returns a Logical representing whether x is equal to y.</div><div class="ttdef"><b>Definition:</b> equal.hpp:64</div></div>
<div class="ttc" id="agroup__group-_comparable_html_gae33be2e0d5e04f19082f4b7740dfc9cd"><div class="ttname"><a href="group__group-_comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd">boost::hana::not_equal</a></div><div class="ttdeci">constexpr auto not_equal</div><div class="ttdoc">Returns a Logical representing whether x is not equal to y.</div><div class="ttdef"><b>Definition:</b> not_equal.hpp:54</div></div>
<div class="ttc" id="agroup__group-_struct_html_gab9efb238a82207d91643994c5295cf8c"><div class="ttname"><a href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">boost::hana::BOOST_HANA_DEFINE_STRUCT</a></div><div class="ttdeci">auto BOOST_HANA_DEFINE_STRUCT(...)</div><div class="ttdoc">Defines members of a structure, while at the same time modeling Struct.</div></div>
<div class="ttc" id="agroup__group-assertions_html_ga4796ae107d58b67e0bbccd5ae6f70101"><div class="ttname"><a href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_RUNTIME_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_RUNTIME_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTIO...</div><div class="ttdef"><b>Definition:</b> assert.hpp:209</div></div>
<div class="ttc" id="akeys_8hpp_html"><div class="ttname"><a href="keys_8hpp.html">keys.hpp</a></div><div class="ttdoc">Defines boost::hana::keys.</div></div>
<div class="ttc" id="anamespaceboost_1_1hana_html"><div class="ttname"><a href="namespaceboost_1_1hana.html">boost::hana</a></div><div class="ttdoc">Namespace containing everything in the library.</div><div class="ttdef"><b>Definition:</b> accessors.hpp:20</div></div>
<div class="ttc" id="anot__equal_8hpp_html"><div class="ttname"><a href="not__equal_8hpp.html">not_equal.hpp</a></div><div class="ttdoc">Defines boost::hana::not_equal.</div></div>
<div class="ttc" id="astring_8hpp_html"><div class="ttname"><a href="string_8hpp.html">string.hpp</a></div><div class="ttdoc">Defines boost::hana::string.</div></div>
</div><!-- fragment --></li>
<li><code>Foldable</code> (free model)<br  />
A <code>Struct</code> can be folded by considering it as a list of pairs each containing the name of a member and the value associated to that member, in the same order as they appear in the <code><a class="el" href="group__group-_struct.html#gad301dd8e9fb4639d7874619c97d6d427" title="Returns a Sequence containing the members of a Struct.">hana::members</a></code> sequence. By default, a model of <code>Foldable</code> doing just that is provided for models of the <code>Struct</code> concept. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="define__struct_8hpp.html">boost/hana/define_struct.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="fold__left_8hpp.html">boost/hana/fold_left.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="second_8hpp.html">boost/hana/second.hpp</a>&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">struct </span>Kitten {</div>
<div class="line">    <a class="code" href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">BOOST_HANA_DEFINE_STRUCT</a>(Kitten,</div>
<div class="line">        (<span class="keywordtype">int</span>, extremely_cute),</div>
<div class="line">        (<span class="keywordtype">int</span>, cute),</div>
<div class="line">        (<span class="keywordtype">int</span>, not_so_cute)</div>
<div class="line">    );</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    constexpr Kitten kitten{5, 10, 0};</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a>(</div>
<div class="line">        hana::fold_left(kitten, 0, [](<span class="keyword">auto</span> total, <span class="keyword">auto</span> member) {</div>
<div class="line">            <span class="comment">// first(member) is the name of the member, here</span></div>
<div class="line">            <span class="comment">// &quot;extremely_cute&quot;, or &quot;cute&quot; or &quot;not_so_cute&quot;,</span></div>
<div class="line">            <span class="comment">// and second(member) is its value.</span></div>
<div class="line">            <span class="keywordflow">return</span> <a class="code" href="group__group-_product.html#ga7bb979d59ffc3ab862cb7d9dc7730077">hana::second</a>(member) + total;</div>
<div class="line">        }) == (5 + 10 + 0)</div>
<div class="line">    );</div>
<div class="line">}</div>
<div class="ttc" id="afold__left_8hpp_html"><div class="ttname"><a href="fold__left_8hpp.html">fold_left.hpp</a></div><div class="ttdoc">Defines boost::hana::fold_left.</div></div>
<div class="ttc" id="agroup__group-_product_html_ga7bb979d59ffc3ab862cb7d9dc7730077"><div class="ttname"><a href="group__group-_product.html#ga7bb979d59ffc3ab862cb7d9dc7730077">boost::hana::second</a></div><div class="ttdeci">constexpr auto second</div><div class="ttdoc">Returns the second element of a pair.</div><div class="ttdef"><b>Definition:</b> second.hpp:32</div></div>
<div class="ttc" id="agroup__group-assertions_html_gac7aafc41e4dcc7d1f1929fb00f010d2a"><div class="ttname"><a href="group__group-assertions.html#gac7aafc41e4dcc7d1f1929fb00f010d2a">BOOST_HANA_CONSTEXPR_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_CONSTEXPR_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_CONSTEXPR_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERT...</div><div class="ttdef"><b>Definition:</b> assert.hpp:300</div></div>
<div class="ttc" id="asecond_8hpp_html"><div class="ttname"><a href="second_8hpp.html">second.hpp</a></div><div class="ttdoc">Defines boost::hana::second.</div></div>
</div><!-- fragment --> Being a model of <code>Foldable</code> makes it possible to turn a <code>Struct</code> into basically any <code>Sequence</code>, but also into a <code><a class="el" href="structboost_1_1hana_1_1map.html" title="Basic associative container requiring unique, Comparable and Hashable keys.">hana::map</a></code> by simply using the <code>to&lt;...&gt;</code> function! <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2to_8hpp.html">boost/hana/core/to.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="define__struct_8hpp.html">boost/hana/define_struct.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="map_8hpp.html">boost/hana/map.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="pair_8hpp.html">boost/hana/pair.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="string_8hpp.html">boost/hana/string.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    <a class="code" href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">BOOST_HANA_DEFINE_STRUCT</a>(Person,</div>
<div class="line">        (std::string, name),</div>
<div class="line">        (<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>, age)</div>
<div class="line">    );</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    Person john{<span class="stringliteral">&quot;John&quot;</span>, 30u};</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::to&lt;hana::map_tag&gt;(john) == hana::make_map(</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), <span class="stringliteral">&quot;John&quot;</span>),</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>), 30u)</div>
<div class="line">    ));</div>
<div class="line">}</div>
<div class="ttc" id="acore_2to_8hpp_html"><div class="ttname"><a href="core_2to_8hpp.html">to.hpp</a></div><div class="ttdoc">Defines boost::hana::to and related utilities.</div></div>
<div class="ttc" id="amap_8hpp_html"><div class="ttname"><a href="map_8hpp.html">map.hpp</a></div><div class="ttdoc">Defines boost::hana::map.</div></div>
<div class="ttc" id="apair_8hpp_html"><div class="ttname"><a href="pair_8hpp.html">pair.hpp</a></div><div class="ttdoc">Defines boost::hana::pair.</div></div>
</div><!-- fragment --></li>
<li><code>Searchable</code> (free model)<br  />
A <code>Struct</code> can be searched by considering it as a map where the keys are the names of the members of the <code>Struct</code>, and the values are the members associated to those names. By default, a model of <code>Searchable</code> is provided for any model of the <code>Struct</code> concept. <div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="accessors_8hpp.html">boost/hana/accessors.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="all__of_8hpp.html">boost/hana/all_of.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="define__struct_8hpp.html">boost/hana/define_struct.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="find_8hpp.html">boost/hana/find.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="second_8hpp.html">boost/hana/second.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="string_8hpp.html">boost/hana/string.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    <a class="code" href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">BOOST_HANA_DEFINE_STRUCT</a>(Person,</div>
<div class="line">        (std::string, name),</div>
<div class="line">        (<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>, age)</div>
<div class="line">    );</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    Person john{<span class="stringliteral">&quot;John&quot;</span>, 30};</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(</div>
<div class="line">        <a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>)) == hana::just(<span class="stringliteral">&quot;John&quot;</span>)</div>
<div class="line">    );</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div>
<div class="line">        <a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;foobar&quot;</span>)) == hana::nothing</div>
<div class="line">    );</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(</div>
<div class="line">        <a class="code" href="group__group-_searchable.html#ga3a168950082f38afd9edf256f336c8ba">hana::all_of</a>(hana::accessors&lt;Person&gt;(), [&amp;](<span class="keyword">auto</span> a) {</div>
<div class="line">            <span class="keywordflow">return</span> <a class="code" href="group__group-_product.html#ga7bb979d59ffc3ab862cb7d9dc7730077">hana::second</a>(a)(john) == <a class="code" href="group__group-_product.html#ga7bb979d59ffc3ab862cb7d9dc7730077">hana::second</a>(a)(john);</div>
<div class="line">        })</div>
<div class="line">    );</div>
<div class="line"> </div>
<div class="line">    <span class="comment">// the above is equivalent to:</span></div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(john, john));</div>
<div class="line">}</div>
<div class="ttc" id="aaccessors_8hpp_html"><div class="ttname"><a href="accessors_8hpp.html">accessors.hpp</a></div><div class="ttdoc">Defines boost::hana::accessors.</div></div>
<div class="ttc" id="aall__of_8hpp_html"><div class="ttname"><a href="all__of_8hpp.html">all_of.hpp</a></div><div class="ttdoc">Defines boost::hana::all_of.</div></div>
<div class="ttc" id="afind_8hpp_html"><div class="ttname"><a href="find_8hpp.html">find.hpp</a></div><div class="ttdoc">Defines boost::hana::find.</div></div>
<div class="ttc" id="agroup__group-_searchable_html_ga3a168950082f38afd9edf256f336c8ba"><div class="ttname"><a href="group__group-_searchable.html#ga3a168950082f38afd9edf256f336c8ba">boost::hana::all_of</a></div><div class="ttdeci">constexpr auto all_of</div><div class="ttdoc">Returns whether all the keys of the structure satisfy the predicate.</div><div class="ttdef"><b>Definition:</b> all_of.hpp:38</div></div>
<div class="ttc" id="agroup__group-_searchable_html_ga6b6cdd69942b0fe3bf5254247f9c861e"><div class="ttname"><a href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">boost::hana::find</a></div><div class="ttdeci">constexpr auto find</div><div class="ttdoc">Finds the value associated to the given key in a structure.</div><div class="ttdef"><b>Definition:</b> find.hpp:44</div></div>
<div class="ttc" id="agroup__group-assertions_html_ga2c5006540936d9f8880e3a39f4fcc035"><div class="ttname"><a href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a></div><div class="ttdeci">#define BOOST_HANA_CONSTANT_CHECK(...)</div><div class="ttdoc">Equivalent to BOOST_HANA_CONSTANT_ASSERT, but not influenced by the BOOST_HANA_CONFIG_DISABLE_ASSERTI...</div><div class="ttdef"><b>Definition:</b> assert.hpp:239</div></div>
<div class="ttc" id="aoptional_8hpp_html"><div class="ttname"><a href="optional_8hpp.html">optional.hpp</a></div><div class="ttdoc">Defines boost::hana::optional.</div></div>
</div><!-- fragment --> </li>
</ol>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga141761435a7826b3cbe646b4f59eaf0a"><td class="memItemLeft" align="right" valign="top">auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_struct.html#ga141761435a7826b3cbe646b4f59eaf0a">boost::hana::BOOST_HANA_ADAPT_ADT</a> (...)</td></tr>
<tr class="memdesc:ga141761435a7826b3cbe646b4f59eaf0a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines a model of <code>Struct</code> with the given accessors.  <a href="group__group-_struct.html#ga141761435a7826b3cbe646b4f59eaf0a">More...</a><br /></td></tr>
<tr class="separator:ga141761435a7826b3cbe646b4f59eaf0a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaba3b4d2cf342bfca773e90fc20bfae91"><td class="memItemLeft" align="right" valign="top">auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_struct.html#gaba3b4d2cf342bfca773e90fc20bfae91">boost::hana::BOOST_HANA_ADAPT_STRUCT</a> (...)</td></tr>
<tr class="memdesc:gaba3b4d2cf342bfca773e90fc20bfae91"><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines a model of <code>Struct</code> with the given members.  <a href="group__group-_struct.html#gaba3b4d2cf342bfca773e90fc20bfae91">More...</a><br /></td></tr>
<tr class="separator:gaba3b4d2cf342bfca773e90fc20bfae91"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gab9efb238a82207d91643994c5295cf8c"><td class="memItemLeft" align="right" valign="top">auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">boost::hana::BOOST_HANA_DEFINE_STRUCT</a> (...)</td></tr>
<tr class="memdesc:gab9efb238a82207d91643994c5295cf8c"><td class="mdescLeft">&#160;</td><td class="mdescRight">Defines members of a structure, while at the same time modeling <code>Struct</code>.  <a href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">More...</a><br /></td></tr>
<tr class="separator:gab9efb238a82207d91643994c5295cf8c"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
Variables</h2></td></tr>
<tr class="memitem:ga983a55dbd93d766fd37689ea32e4ddfb"><td class="memTemplParams" colspan="2">template&lt;typename S &gt; </td></tr>
<tr class="memitem:ga983a55dbd93d766fd37689ea32e4ddfb"><td class="memTemplItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memTemplItemRight" valign="bottom"><a class="el" href="group__group-_struct.html#ga983a55dbd93d766fd37689ea32e4ddfb">boost::hana::accessors</a></td></tr>
<tr class="memdesc:ga983a55dbd93d766fd37689ea32e4ddfb"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code>Sequence</code> of pairs representing the accessors of the data structure.  <a href="group__group-_struct.html#ga983a55dbd93d766fd37689ea32e4ddfb">More...</a><br /></td></tr>
<tr class="separator:ga983a55dbd93d766fd37689ea32e4ddfb"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf8c7199742581e6e66c8397def68e2d3"><td class="memItemLeft" align="right" valign="top">constexpr keys_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_struct.html#gaf8c7199742581e6e66c8397def68e2d3">boost::hana::keys</a> {}</td></tr>
<tr class="memdesc:gaf8c7199742581e6e66c8397def68e2d3"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code>Sequence</code> containing the name of the members of the data structure.  <a href="group__group-_struct.html#gaf8c7199742581e6e66c8397def68e2d3">More...</a><br /></td></tr>
<tr class="separator:gaf8c7199742581e6e66c8397def68e2d3"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gad301dd8e9fb4639d7874619c97d6d427"><td class="memItemLeft" align="right" valign="top">constexpr auto&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group-_struct.html#gad301dd8e9fb4639d7874619c97d6d427">boost::hana::members</a></td></tr>
<tr class="memdesc:gad301dd8e9fb4639d7874619c97d6d427"><td class="mdescLeft">&#160;</td><td class="mdescRight">Returns a <code>Sequence</code> containing the members of a <code>Struct</code>.  <a href="group__group-_struct.html#gad301dd8e9fb4639d7874619c97d6d427">More...</a><br /></td></tr>
<tr class="separator:gad301dd8e9fb4639d7874619c97d6d427"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga141761435a7826b3cbe646b4f59eaf0a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga141761435a7826b3cbe646b4f59eaf0a">&#9670;&nbsp;</a></span>BOOST_HANA_ADAPT_ADT()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">auto boost::hana::BOOST_HANA_ADAPT_ADT </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>...</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2adapt__adt_8hpp.html">boost/hana/fwd/adapt_adt.hpp</a>&gt;</code></p>

<p>Defines a model of <code>Struct</code> with the given accessors. </p>
<p>Using this macro at <em>global scope</em> will define a model of the <code>Struct</code> concept for the given type. This can be used to easily adapt existing user-defined types in a ad-hoc manner. Unlike <code>BOOST_HANA_ADAPT_STRUCT</code>, this macro requires specifying the way to retrieve each member by providing a function that does the extraction.</p>
<dl class="section note"><dt>Note</dt><dd>This macro only works if the tag of the user-defined type <code>T</code> is <code>T</code> itself. This is the case unless you specifically asked for something different; see <code><a class="el" href="structboost_1_1hana_1_1tag__of.html" title="Metafunction returning the tag associated to T.">tag_of</a></code>'s documentation.</dd></dl>
<h2><a class="anchor" id="autotoc_md46"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="accessors_8hpp.html">boost/hana/accessors.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="adapt__adt_8hpp.html">boost/hana/adapt_adt.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2to_8hpp.html">boost/hana/core/to.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="find_8hpp.html">boost/hana/find.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="first_8hpp.html">boost/hana/first.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="map_8hpp.html">boost/hana/map.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="pair_8hpp.html">boost/hana/pair.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="string_8hpp.html">boost/hana/string.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="transform_8hpp.html">boost/hana/transform.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">namespace </span>ns {</div>
<div class="line">    <span class="keyword">struct </span>Person {</div>
<div class="line">        <span class="keyword">explicit</span> Person(std::string <span class="keyword">const</span>&amp; name, <span class="keywordtype">int</span> age)</div>
<div class="line">            : name_(name), age_(age)</div>
<div class="line">        { }</div>
<div class="line">        std::string <span class="keyword">const</span>&amp; get_name()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> name_; }</div>
<div class="line">        <span class="keywordtype">int</span> get_age()<span class="keyword"> const </span>{ <span class="keywordflow">return</span> age_; }</div>
<div class="line"> </div>
<div class="line">    <span class="keyword">private</span>:</div>
<div class="line">        std::string name_;</div>
<div class="line">        <span class="keywordtype">int</span> age_;</div>
<div class="line">    };</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-_struct.html#ga141761435a7826b3cbe646b4f59eaf0a">BOOST_HANA_ADAPT_ADT</a>(ns::Person,</div>
<div class="line">    (name, [](ns::Person <span class="keyword">const</span>&amp; p) { <span class="keywordflow">return</span> p.get_name(); }),</div>
<div class="line">    (age, [](ns::Person <span class="keyword">const</span>&amp; p) { <span class="keywordflow">return</span> p.get_age(); })</div>
<div class="line">);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// The member names are hana::strings:</span></div>
<div class="line"><span class="keyword">auto</span> names = hana::transform(hana::accessors&lt;ns::Person&gt;(), <a class="code" href="group__group-_product.html#ga34bbf4281de06dc3540441e8b2bd24f4">hana::first</a>);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div>
<div class="line">    names == hana::make_tuple(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>))</div>
<div class="line">);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    ns::Person john{<span class="stringliteral">&quot;John&quot;</span>, 30}, bob{<span class="stringliteral">&quot;Bob&quot;</span>, 40};</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(john, john));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd">hana::not_equal</a>(john, bob));</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>)) == hana::just(<span class="stringliteral">&quot;John&quot;</span>));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>)) == hana::just(30));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;foo&quot;</span>)) == hana::nothing);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::to_tuple(john) == hana::make_tuple(</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), <span class="stringliteral">&quot;John&quot;</span>),</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>), 30)</div>
<div class="line">    ));</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::to_map(john) == hana::make_map(</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), <span class="stringliteral">&quot;John&quot;</span>),</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>), 30)</div>
<div class="line">    ));</div>
<div class="line">}</div>
<div class="ttc" id="aadapt__adt_8hpp_html"><div class="ttname"><a href="adapt__adt_8hpp.html">adapt_adt.hpp</a></div><div class="ttdoc">Defines the BOOST_HANA_ADAPT_ADT macro.</div></div>
<div class="ttc" id="afirst_8hpp_html"><div class="ttname"><a href="first_8hpp.html">first.hpp</a></div><div class="ttdoc">Defines boost::hana::first.</div></div>
<div class="ttc" id="agroup__group-_product_html_ga34bbf4281de06dc3540441e8b2bd24f4"><div class="ttname"><a href="group__group-_product.html#ga34bbf4281de06dc3540441e8b2bd24f4">boost::hana::first</a></div><div class="ttdeci">constexpr auto first</div><div class="ttdoc">Returns the first element of a pair.</div><div class="ttdef"><b>Definition:</b> first.hpp:33</div></div>
<div class="ttc" id="agroup__group-_struct_html_ga141761435a7826b3cbe646b4f59eaf0a"><div class="ttname"><a href="group__group-_struct.html#ga141761435a7826b3cbe646b4f59eaf0a">boost::hana::BOOST_HANA_ADAPT_ADT</a></div><div class="ttdeci">auto BOOST_HANA_ADAPT_ADT(...)</div><div class="ttdoc">Defines a model of Struct with the given accessors.</div></div>
<div class="ttc" id="atransform_8hpp_html"><div class="ttname"><a href="transform_8hpp.html">transform.hpp</a></div><div class="ttdoc">Defines boost::hana::transform.</div></div>
<div class="ttc" id="atuple_8hpp_html"><div class="ttname"><a href="tuple_8hpp.html">tuple.hpp</a></div><div class="ttdoc">Defines boost::hana::tuple.</div></div>
</div><!-- fragment --> 
</div>
</div>
<a id="gaba3b4d2cf342bfca773e90fc20bfae91"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaba3b4d2cf342bfca773e90fc20bfae91">&#9670;&nbsp;</a></span>BOOST_HANA_ADAPT_STRUCT()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">auto boost::hana::BOOST_HANA_ADAPT_STRUCT </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>...</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2adapt__struct_8hpp.html">boost/hana/fwd/adapt_struct.hpp</a>&gt;</code></p>

<p>Defines a model of <code>Struct</code> with the given members. </p>
<p>Using this macro at <em>global scope</em> will define a model of the <code>Struct</code> concept for the given type. This can be used to easily adapt existing user-defined types in a ad-hoc manner. Unlike the <code>BOOST_HANA_DEFINE_STRUCT</code> macro, this macro does not require the types of the members to be specified.</p>
<dl class="section note"><dt>Note</dt><dd>This macro only works if the tag of the user-defined type <code>T</code> is <code>T</code> itself. This is the case unless you specifically asked for something different; see <code><a class="el" href="structboost_1_1hana_1_1tag__of.html" title="Metafunction returning the tag associated to T.">tag_of</a></code>'s documentation.</dd></dl>
<h2><a class="anchor" id="autotoc_md47"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="accessors_8hpp.html">boost/hana/accessors.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="adapt__struct_8hpp.html">boost/hana/adapt_struct.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2to_8hpp.html">boost/hana/core/to.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="find_8hpp.html">boost/hana/find.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="first_8hpp.html">boost/hana/first.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="map_8hpp.html">boost/hana/map.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="pair_8hpp.html">boost/hana/pair.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="string_8hpp.html">boost/hana/string.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="transform_8hpp.html">boost/hana/transform.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">namespace </span>ns {</div>
<div class="line">    <span class="keyword">struct </span>Person {</div>
<div class="line">        std::string name;</div>
<div class="line">        <span class="keywordtype">int</span> age;</div>
<div class="line">    };</div>
<div class="line">}</div>
<div class="line"> </div>
<div class="line"><a class="code" href="group__group-_struct.html#gaba3b4d2cf342bfca773e90fc20bfae91">BOOST_HANA_ADAPT_STRUCT</a>(ns::Person,</div>
<div class="line">    name,</div>
<div class="line">    age</div>
<div class="line">);</div>
<div class="line"> </div>
<div class="line"><span class="comment">// The member names are hana::strings:</span></div>
<div class="line"><span class="keyword">auto</span> names = hana::transform(hana::accessors&lt;ns::Person&gt;(), <a class="code" href="group__group-_product.html#ga34bbf4281de06dc3540441e8b2bd24f4">hana::first</a>);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div>
<div class="line">    names == hana::make_tuple(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>))</div>
<div class="line">);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    ns::Person john{<span class="stringliteral">&quot;John&quot;</span>, 30}, bob{<span class="stringliteral">&quot;Bob&quot;</span>, 40};</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(john, john));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd">hana::not_equal</a>(john, bob));</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>)) == hana::just(<span class="stringliteral">&quot;John&quot;</span>));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>)) == hana::just(30));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;foo&quot;</span>)) == hana::nothing);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::to_tuple(john) == hana::make_tuple(</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), <span class="stringliteral">&quot;John&quot;</span>),</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>), 30)</div>
<div class="line">    ));</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::to_map(john) == hana::make_map(</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), <span class="stringliteral">&quot;John&quot;</span>),</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>), 30)</div>
<div class="line">    ));</div>
<div class="line">}</div>
<div class="ttc" id="aadapt__struct_8hpp_html"><div class="ttname"><a href="adapt__struct_8hpp.html">adapt_struct.hpp</a></div><div class="ttdoc">Defines the BOOST_HANA_ADAPT_STRUCT macro.</div></div>
<div class="ttc" id="agroup__group-_struct_html_gaba3b4d2cf342bfca773e90fc20bfae91"><div class="ttname"><a href="group__group-_struct.html#gaba3b4d2cf342bfca773e90fc20bfae91">boost::hana::BOOST_HANA_ADAPT_STRUCT</a></div><div class="ttdeci">auto BOOST_HANA_ADAPT_STRUCT(...)</div><div class="ttdoc">Defines a model of Struct with the given members.</div></div>
</div><!-- fragment --> 
</div>
</div>
<a id="gab9efb238a82207d91643994c5295cf8c"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gab9efb238a82207d91643994c5295cf8c">&#9670;&nbsp;</a></span>BOOST_HANA_DEFINE_STRUCT()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">auto boost::hana::BOOST_HANA_DEFINE_STRUCT </td>
          <td>(</td>
          <td class="paramtype">&#160;</td>
          <td class="paramname"><em>...</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2define__struct_8hpp.html">boost/hana/fwd/define_struct.hpp</a>&gt;</code></p>

<p>Defines members of a structure, while at the same time modeling <code>Struct</code>. </p>
<p>Using this macro in the body of a user-defined type will define the given members inside that type, and will also provide a model of the <code>Struct</code> concept for that user-defined type. This macro is often the easiest way to define a model of the <code>Struct</code> concept.</p>
<dl class="section note"><dt>Note</dt><dd>This macro only works if the tag of the user-defined type <code>T</code> is <code>T</code> itself. This is the case unless you specifically asked for something different; see <code><a class="el" href="structboost_1_1hana_1_1tag__of.html" title="Metafunction returning the tag associated to T.">tag_of</a></code>'s documentation.</dd></dl>
<h2><a class="anchor" id="autotoc_md202"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="accessors_8hpp.html">boost/hana/accessors.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="core_2to_8hpp.html">boost/hana/core/to.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="define__struct_8hpp.html">boost/hana/define_struct.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="find_8hpp.html">boost/hana/find.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="first_8hpp.html">boost/hana/first.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="map_8hpp.html">boost/hana/map.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="not__equal_8hpp.html">boost/hana/not_equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="optional_8hpp.html">boost/hana/optional.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="pair_8hpp.html">boost/hana/pair.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="string_8hpp.html">boost/hana/string.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="transform_8hpp.html">boost/hana/transform.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    <a class="code" href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">BOOST_HANA_DEFINE_STRUCT</a>(Person,</div>
<div class="line">        (std::string, name),</div>
<div class="line">        (<span class="keywordtype">int</span>, age)</div>
<div class="line">    );</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="comment">// The member names are hana::strings:</span></div>
<div class="line"><span class="keyword">auto</span> names = hana::transform(hana::accessors&lt;Person&gt;(), <a class="code" href="group__group-_product.html#ga34bbf4281de06dc3540441e8b2bd24f4">hana::first</a>);</div>
<div class="line"><a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div>
<div class="line">    names == hana::make_tuple(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>))</div>
<div class="line">);</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    Person john{<span class="stringliteral">&quot;John&quot;</span>, 30}, bob{<span class="stringliteral">&quot;Bob&quot;</span>, 40};</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_comparable.html#gacaf1ebea6b3ab96ac9dcb82f0e64e547">hana::equal</a>(john, john));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_comparable.html#gae33be2e0d5e04f19082f4b7740dfc9cd">hana::not_equal</a>(john, bob));</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>)) == hana::just(<span class="stringliteral">&quot;John&quot;</span>));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>)) == hana::just(30));</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(<a class="code" href="group__group-_searchable.html#ga6b6cdd69942b0fe3bf5254247f9c861e">hana::find</a>(john, BOOST_HANA_STRING(<span class="stringliteral">&quot;foo&quot;</span>)) == hana::nothing);</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::to_tuple(john) == hana::make_tuple(</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), <span class="stringliteral">&quot;John&quot;</span>),</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>), 30)</div>
<div class="line">    ));</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(hana::to_map(john) == hana::make_map(</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>), <span class="stringliteral">&quot;John&quot;</span>),</div>
<div class="line">        hana::make_pair(BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>), 30)</div>
<div class="line">    ));</div>
<div class="line">}</div>
</div><!-- fragment --> 
</div>
</div>
<h2 class="groupheader">Variable Documentation</h2>
<a id="ga983a55dbd93d766fd37689ea32e4ddfb"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga983a55dbd93d766fd37689ea32e4ddfb">&#9670;&nbsp;</a></span>accessors</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename S &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto boost::hana::accessors</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2accessors_8hpp.html">boost/hana/fwd/accessors.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= []() {</div>
<div class="line">        <span class="keywordflow">return</span> tag-dispatched;</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Returns a <code>Sequence</code> of pairs representing the accessors of the data structure. </p>
<p>Given a <code>Struct</code> <code>S</code>, <code>accessors&lt;S&gt;()</code> is a <code>Sequence</code> of <code>Product</code>s where the first element of each pair is the "name" of a member of the <code>Struct</code>, and the second element of each pair is a function that can be used to access that member when given an object of the proper data type. As described in the global documentation for <code>Struct</code>, the accessor functions in this sequence must be move-independent.</p>
<h2><a class="anchor" id="autotoc_md45"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="accessors_8hpp.html">boost/hana/accessors.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="at_8hpp.html">boost/hana/at.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="define__struct_8hpp.html">boost/hana/define_struct.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="first_8hpp.html">boost/hana/first.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="integral__constant_8hpp.html">boost/hana/integral_constant.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="second_8hpp.html">boost/hana/second.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="string_8hpp.html">boost/hana/string.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    <a class="code" href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">BOOST_HANA_DEFINE_STRUCT</a>(Person,</div>
<div class="line">        (std::string, name),</div>
<div class="line">        (<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>, age)</div>
<div class="line">    );</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    constexpr <span class="keyword">auto</span> <a class="code" href="group__group-_struct.html#ga983a55dbd93d766fd37689ea32e4ddfb">accessors</a> = hana::accessors&lt;Person&gt;();</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div>
<div class="line">        <a class="code" href="group__group-_product.html#ga34bbf4281de06dc3540441e8b2bd24f4">hana::first</a>(<a class="code" href="group__group-_struct.html#ga983a55dbd93d766fd37689ea32e4ddfb">accessors</a>[hana::size_c&lt;0&gt;]) == BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>)</div>
<div class="line">    );</div>
<div class="line"> </div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div>
<div class="line">        <a class="code" href="group__group-_product.html#ga34bbf4281de06dc3540441e8b2bd24f4">hana::first</a>(<a class="code" href="group__group-_struct.html#ga983a55dbd93d766fd37689ea32e4ddfb">accessors</a>[hana::size_c&lt;1&gt;]) == BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>)</div>
<div class="line">    );</div>
<div class="line"> </div>
<div class="line">    constexpr <span class="keyword">auto</span> get_name = <a class="code" href="group__group-_product.html#ga7bb979d59ffc3ab862cb7d9dc7730077">hana::second</a>(<a class="code" href="group__group-_struct.html#ga983a55dbd93d766fd37689ea32e4ddfb">accessors</a>[hana::size_c&lt;0&gt;]);</div>
<div class="line">    constexpr <span class="keyword">auto</span> get_age = <a class="code" href="group__group-_product.html#ga7bb979d59ffc3ab862cb7d9dc7730077">hana::second</a>(<a class="code" href="group__group-_struct.html#ga983a55dbd93d766fd37689ea32e4ddfb">accessors</a>[hana::size_c&lt;1&gt;]);</div>
<div class="line"> </div>
<div class="line">    Person john{<span class="stringliteral">&quot;John&quot;</span>, 30};</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(get_name(john) == <span class="stringliteral">&quot;John&quot;</span>);</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(get_age(john) == 30);</div>
<div class="line">}</div>
<div class="ttc" id="aat_8hpp_html"><div class="ttname"><a href="at_8hpp.html">at.hpp</a></div><div class="ttdoc">Defines boost::hana::at and boost::hana::at_c.</div></div>
<div class="ttc" id="agroup__group-_struct_html_ga983a55dbd93d766fd37689ea32e4ddfb"><div class="ttname"><a href="group__group-_struct.html#ga983a55dbd93d766fd37689ea32e4ddfb">boost::hana::accessors</a></div><div class="ttdeci">constexpr auto accessors</div><div class="ttdoc">Returns a Sequence of pairs representing the accessors of the data structure.</div><div class="ttdef"><b>Definition:</b> accessors.hpp:35</div></div>
<div class="ttc" id="aintegral__constant_8hpp_html"><div class="ttname"><a href="integral__constant_8hpp.html">integral_constant.hpp</a></div><div class="ttdoc">Defines boost::hana::integral_constant.</div></div>
</div><!-- fragment --> 
</div>
</div>
<a id="gaf8c7199742581e6e66c8397def68e2d3"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf8c7199742581e6e66c8397def68e2d3">&#9670;&nbsp;</a></span>keys</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto boost::hana::keys {}</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">related</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2keys_8hpp.html">boost/hana/fwd/keys.hpp</a>&gt;</code></p>

<p>Returns a <code>Sequence</code> containing the name of the members of the data structure. </p>
<p>Given a <code>Struct</code> object, <code>keys</code> returns a <code>Sequence</code> containing the name of all the members of the <code>Struct</code>, in the same order as they appear in the <code>accessors</code> sequence.</p>
<h2><a class="anchor" id="autotoc_md249"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="define__struct_8hpp.html">boost/hana/define_struct.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="keys_8hpp.html">boost/hana/keys.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="string_8hpp.html">boost/hana/string.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    <a class="code" href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">BOOST_HANA_DEFINE_STRUCT</a>(Person,</div>
<div class="line">        (std::string, name),</div>
<div class="line">        (<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>, age)</div>
<div class="line">    );</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    Person john{<span class="stringliteral">&quot;John&quot;</span>, 30};</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga2c5006540936d9f8880e3a39f4fcc035">BOOST_HANA_CONSTANT_CHECK</a>(</div>
<div class="line">        <a class="code" href="group__group-_struct.html#gaf8c7199742581e6e66c8397def68e2d3">hana::keys</a>(john) == hana::make_tuple(BOOST_HANA_STRING(<span class="stringliteral">&quot;name&quot;</span>),</div>
<div class="line">                                             BOOST_HANA_STRING(<span class="stringliteral">&quot;age&quot;</span>))</div>
<div class="line">    );</div>
<div class="line">}</div>
<div class="ttc" id="agroup__group-_struct_html_gaf8c7199742581e6e66c8397def68e2d3"><div class="ttname"><a href="group__group-_struct.html#gaf8c7199742581e6e66c8397def68e2d3">boost::hana::keys</a></div><div class="ttdeci">constexpr keys_t keys</div><div class="ttdoc">Returns a Sequence containing the name of the members of the data structure.</div><div class="ttdef"><b>Definition:</b> keys.hpp:29</div></div>
</div><!-- fragment --> 
</div>
</div>
<a id="gad301dd8e9fb4639d7874619c97d6d427"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gad301dd8e9fb4639d7874619c97d6d427">&#9670;&nbsp;</a></span>members</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">constexpr auto boost::hana::members</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">constexpr</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p><code>#include &lt;<a class="el" href="fwd_2members_8hpp.html">boost/hana/fwd/members.hpp</a>&gt;</code></p>
<b>Initial value:</b><div class="fragment"><div class="line">= [](<span class="keyword">auto</span>&amp;&amp; object) {</div>
<div class="line">        <span class="keywordflow">return</span> tag-dispatched;</div>
<div class="line">    }</div>
</div><!-- fragment -->
<p>Returns a <code>Sequence</code> containing the members of a <code>Struct</code>. </p>
<p>Given a <code>Struct</code> object, <code>members</code> returns a <code>Sequence</code> containing all the members of the <code>Struct</code>, in the same order as their respective accessor appears in the <code>accessors</code> sequence.</p>
<h2><a class="anchor" id="autotoc_md276"></a>
Example</h2>
<div class="fragment"><div class="line"><span class="comment">// Copyright Louis Dionne 2013-2017</span></div>
<div class="line"><span class="comment">// Distributed under the Boost Software License, Version 1.0.</span></div>
<div class="line"><span class="comment">// (See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="assert_8hpp.html">boost/hana/assert.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="define__struct_8hpp.html">boost/hana/define_struct.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="equal_8hpp.html">boost/hana/equal.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="members_8hpp.html">boost/hana/members.hpp</a>&gt;</span></div>
<div class="line"><span class="preprocessor">#include &lt;<a class="code" href="tuple_8hpp.html">boost/hana/tuple.hpp</a>&gt;</span></div>
<div class="line"> </div>
<div class="line"><span class="preprocessor">#include &lt;string&gt;</span></div>
<div class="line"><span class="keyword">namespace </span>hana = <a class="code" href="namespaceboost_1_1hana.html">boost::hana</a>;</div>
<div class="line"> </div>
<div class="line"> </div>
<div class="line"><span class="keyword">struct </span>Person {</div>
<div class="line">    <a class="code" href="group__group-_struct.html#gab9efb238a82207d91643994c5295cf8c">BOOST_HANA_DEFINE_STRUCT</a>(Person,</div>
<div class="line">        (std::string, name),</div>
<div class="line">        (<span class="keywordtype">unsigned</span> <span class="keywordtype">short</span>, age)</div>
<div class="line">    );</div>
<div class="line">};</div>
<div class="line"> </div>
<div class="line"><span class="keywordtype">int</span> main() {</div>
<div class="line">    Person john{<span class="stringliteral">&quot;John&quot;</span>, 30};</div>
<div class="line">    <a class="code" href="group__group-assertions.html#ga4796ae107d58b67e0bbccd5ae6f70101">BOOST_HANA_RUNTIME_CHECK</a>(<a class="code" href="group__group-_struct.html#gad301dd8e9fb4639d7874619c97d6d427">hana::members</a>(john) == hana::make_tuple(<span class="stringliteral">&quot;John&quot;</span>, 30));</div>
<div class="line">}</div>
<div class="ttc" id="agroup__group-_struct_html_gad301dd8e9fb4639d7874619c97d6d427"><div class="ttname"><a href="group__group-_struct.html#gad301dd8e9fb4639d7874619c97d6d427">boost::hana::members</a></div><div class="ttdeci">constexpr auto members</div><div class="ttdoc">Returns a Sequence containing the members of a Struct.</div><div class="ttdef"><b>Definition:</b> members.hpp:30</div></div>
<div class="ttc" id="amembers_8hpp_html"><div class="ttname"><a href="members_8hpp.html">members.hpp</a></div><div class="ttdoc">Defines boost::hana::members.</div></div>
</div><!-- fragment --> 
</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!--
Copyright Louis Dionne 2013-2017
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE.md or copy at http://boost.org/LICENSE_1_0.txt)
-->
<!-- boost-no-inspect -->
<!-- HTML footer for doxygen 1.8.9.1-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
  </ul>
</div>
</body>
</html>
